<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>行政站点</title>
	<link rel="stylesheet" href="../../libs/node_modules/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" href="../../style/common.css">
	<link rel="stylesheet" href="../../style/home/sitelist.css">
	<link rel="stylesheet" href="../../style/investigation/investigation.css">

	<script src="../../libs/vue.js"></script>
	<script src="../../jsc/vue-router.js"></script>
	<script src="../../libs/jquery-3.2.1.min.js"></script>
	<script src="../../jsc/axios.min.js"></script>
	<script src="../../libs/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
	<script src="../../libs/layer-v3.1.1/layer/layer.js"></script>
	<link rel="stylesheet" href="../../style/home/article.css">
</head>
<body>
<div id="app" v-cloak>
	<header-component></header-component>
	<navsearch-component></navsearch-component>

	<!-- 主站导航 -->
	<navrow-component v-if="sitelevel == ''" v-if="site_data && site_data.site_id" :siteid="site_data"></navrow-component>
	<!-- 行政站导航 -->
	<navtab2-component v-if="sitelevel != 5 && sitelevel != '' " v-if="site_data && site_data.site_id" :siteid="site_data"></navtab2-component>
	<!-- 基层站导航 -->
	<navtab3-component v-if="sitelevel==5" v-if="site_data && site_data.site_id" :siteid="site_data"></navtab3-component>
	<main class="site">
		<div class="site-top">
			<div class="site-logo">
				<img src="../../static/icons/logo-icon.png" height="31" width="32"/>
			</div>
			<div class="site-title" @click="back">
				<p>{{ txt }}</p>
				<p class="ccc">HOT</p>
			</div>
		</div>
		<div class="line"></div>
		<div class="site-list" v-if="!isdetail">
			<div class="item" v-for="item in list" @click="detail(item.id)">
				<div class="left">
					<img :src="item.coverimages_text[0]"/>
				</div>
				<div class="right">
					<p class="title">{{ item.title }}</p>
					<p class="info">
						<span> 发布于：{{ item.resource }} </span>
						<span>{{ item.publishtime_text }}</span>
<!--						<span>评论：{{ item.comment }}</span>-->
					</p>
					<div class="summary">
						<div>{{item.postcontent | textFilter}}</div>
					</div>
				</div>
			</div>
		</div>
		<sitedetail v-if="isdetail" :id="articleid" iscomment="false"></sitedetail>
	</main>
	<v-pagination v-if="total&& !isdetail" :total="total" :display="limit" :currentPage="page" v-on:pagechange="togglePage"></v-pagination>
	<suspension-component></suspension-component>
	<footer-component></footer-component>
</div>
<script src="../../jsc/common.js"></script>
<script src="../../jsc/component.js"></script>
<script>
	$(window).resize(function(){
		var width_window = $(window).width();
		var width_div    = $(".content").width();
		var left         = (width_window - width_div) / 2 + width_div + 30;
		$(".suspension").css({ "left" : left });
	});

	//获取窗口可视范围的高度
	function getClientHeight(){
		var clientHeight = 0;
		if( document.body.clientHeight && document.documentElement.clientHeight ){
			var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
		}else{
			var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
		}
		return clientHeight;
	}

	function getScrollTop(){
		var scrollTop = 0;
		if( document.documentElement && document.documentElement.scrollTop ){
			scrollTop = document.documentElement.scrollTop;
		}else if( document.body ){
			scrollTop = document.body.scrollTop;
		}
		return scrollTop;
	}

	function getScrollHeight(){
		return Math.max(document.body.scrollHeight , document.documentElement.scrollHeight);
	}

	$(window).scroll(function(){
		var height  = getClientHeight() ,
			// 窗口滚动条高度
			theight = getScrollTop() ,
			// 窗口可视范围的高度
			rheight = getScrollHeight() ,
			// 滚动条距离底部的高度
			bheight = rheight - theight - height;
		if( document.documentElement.scrollTop >= 200 && bheight > 400 ){
			$(".suspension").show();
		}else{
			$(".suspension").hide();
		}
	});
	var userAgent = navigator.userAgent.toLowerCase();
	var platform;
	if( userAgent == null || userAgent == '' ){
		platform = 'WEB';
	}else{
		if( userAgent.indexOf("android") != -1 ){
			platform      = 'ANDROID';
			location.href = "views/wap/index.html";
		}else if( userAgent.indexOf("ios") != -1 || userAgent.indexOf("iphone") != -1 || userAgent.indexOf("ipad") != -1 ){
			platform      = 'IOS';
			location.href = "views/wap/index.html";
		}else if( userAgent.indexOf("windows phone") != -1 ){
			platform      = 'WP';
			location.href = "views/wap/index.html";
		}else{
			platform = 'WEB';
			//            location.href = "#";
		}
	}

</script>
<script>
	var site = parameter.siteid ? { id : parseInt(parameter.siteid) , name : parseInt(parameter.sitename) } : ( JSON.parse(window.localStorage.getItem("station")) || {} );

	new Vue({
		el:"#app",
		data    : {
			parameter:parameter,
			sitelevel:'',
			site_data:site,
			limit:10,
			page:1,
			total:1,
			id:'',
			txt:'',
			list:[],
			articleid:'',
			isdetail:false,
		} ,
		mounted(){
			if (localStorage.getItem('station')){
				this.sitelevel = JSON.parse(localStorage.getItem('station')).site_level;
				this.site = JSON.parse(localStorage.getItem('station'));
				if (this.parameter.type){
					this.id = this.parameter.category_id
				}else{
					this.id = this.parameter.id;
				}
				// 行政站
				if (this.sitelevel!=5&&this.sitelevel!=''){
					console.log('行政站');
					if (this.parameter.type){
						console.log(decodeURI(this.parameter.category_name));
						this.txt = decodeURI(this.parameter.category_name)
					}else{
						switch (this.id) {
							case '73':
								this.txt = '政府公告';
								break;
							case '74':
								this.txt = '政府动态';
								break;
							case '75':
								this.txt = '党建工作';
								break;
							case '111':
								this.txt = '便民服务';
								break;
							case '112':
								this.txt = '家园服务';
								break;

						}
					}
				}else{
					console.log('基层站');
					//	基层站
					// 54:=跑腿办事，55=任务发布,56=任务大厅,47=政府管理,48=民主管理,49=委员会工作,50=服务管理,51=基层管理
					if (this.parameter.type){
						this.txt = decodeURI(this.parameter.category_name)
					} else{
						switch (this.id) {
							case '47':
								this.txt = '政府管理';
								break;
							case '48':
								this.txt = '民主管理';
								break;
							case '49':
								this.txt = '委员会工作';
								break;
							case '50':
								this.txt = '服务管理';
								break;
							case '51':
								this.txt = '基层管理';
								break;
							case '113':
								this.txt = '我的家园';
								break;
							case '111':
								this.txt = '便民服务';
								break;
							case '112':
								this.txt = '家园服务中心';
								break;
						}
					}
				}
			}
			// 行政站 ： category_id :  73=政府公告,74=政府动态,75=党建工作

			if (this.parameter.type){
				this.isdetail = true;
				this.detail(this.parameter.id)
			} else{
				this.getlist();
			}
		} ,
		methods : {
			getlist(){
				let d = new FormData();
				d.append('site_id',this.site.site_id||'');
				d.append('category_id',this.id);
				d.append('limit',this.limit);
				d.append('page',this.page);
				if (this.parameter.type){
					axios.post(sysurl+'index/articleList',d).then(res=>{
						this.total = res.data.data.total;
						this.list = res.data.data.data;
					})
				}else{
					axios.post(sysurl+'article/areaArticleList',d).then(res=>{
						this.total = res.data.data.total;
						this.list = res.data.data.data;
					})
				}

			},
			togglePage(page){
				this.page = page;
				this.getlist()
			},
			// 查看详情
			detail(id){
				this.articleid = id;
				this.isdetail = true
			},
			back(){
				this.articleid = '';
				this.isdetail = false;
				this.getlist();
			}

		},
		filters:{
			// 过滤中文
			textFilter(txt){
				var str;
				str = txt.match(regHtml,"");
				return str.join("");
			}
		},
	})




</script>
</body>
</html>
